<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/validation.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>增加房间走表</title>
<link href="${ctx}/styles/mainmenu2.css" rel="stylesheet"  type="text/css">
<style>
.2td_listTable_record_off{
	background-color:#fefefe;
	padding-top:6px;
	padding-bottom:1px;
	padding-left:5px;

	cursor:pointer;
	vertical-align: top;
	}
.2td_listTable_record_on{
	background-color:#feec8c;
	padding-top:6px;
	padding-bottom:1px;
	padding-left:5px;
	cursor:pointer;
	}
</style>
<script type="text/javascript">
   var countNumber=0;

   function addNameTR(buildingId,areaName,buildingName)
    {
         var trArray = document.getElementsByName("nameTr");
         if(trArray){

            for (var i = 0; i < trArray.length; i++)
            {
                if(trArray[i].name==buildingId)return false;
            }

         }

        var table    = document.getElementById("tableBody");

        var tr = document.createElement('tr');
        tr.id = "nameTr";
        tr.name=buildingId;

        table.appendChild(tr);

        var td = document.createElement('td');
        tr.appendChild(td);
        var delHref = "<a href='javascript:void(0);' onclick=\"delTR(this);\"><img src='${ctx}/images/ico_delete.gif' alt='删除' width='16' height='16' border='0' align='absbottom'></a>";
        td.innerHTML = areaName + "(" + buildingName + ")&nbsp;&nbsp;" + delHref;
    }

    function delTR(link)
    {

            var table = document.getElementById("tableBody");

            table.removeChild(link.parentElement.parentElement);

    }

     function submitTable()
    {
        var trArray = document.getElementsByName("nameTr");

        var buildingIdStrTemp="";

        if(trArray){

            for (var i = 0; i < trArray.length; i++)
            {
                var tr = trArray[i];
                buildingIdStrTemp=buildingIdStrTemp+""+tr.name+",";
            }


        }
        document.getElementById("buildingIdStr").value=buildingIdStrTemp;
        if(document.getElementById("buildingIdStr").value==''){
           validationAlert("selectSpanMessage",true,"请选择一个楼栋");
           return false;
        } else {
           validationAlert("selectSpanMessage",false,"请选择一个楼栋");
        }
        var isTrue=$("addHouseMeterForm").fireEvent("onSubmit");

        if(isTrue){
         $("meterTypeName").value=$("meterTypeId").options[$('meterTypeId').selectedIndex].text

          var table = document.getElementById("tableBody");
          do{
             if(trArray.length==0)break;
              table.removeChild(trArray[0]);
          }while(document.getElementsByName("nameTr"))


        $("addHouseMeterForm").submit();
        }

    }

</script>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><span class="window_head_intext"><img src="${ctx}/images/ico_Advance.gif" align="absmiddle">&nbsp;增加房间走表</span></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>

  <tr>
    <td class="content">
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="outtable">
  <tr>
    <td>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
        <td class="aux_outtable_color">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>

		<table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
        <tr><form id="addHouseMeterForm" name="addHouseMeterForm" method="post" action="${ctx}/house_meterAction.do?method=addHouseMeter" class="required-validate">
        <input type="hidden" name="buildingIdStr" value=""/>
        <input type="hidden" name="meterTypeName" value=""/>
          <td class="aux_intable_td1">走表类型：</td>
          <td class="aux_intable_require">
          <pms:unitedSelect id="meterTypeId"
	         selectText="请选择..."
	         className="select-one-required"
	         style="width:114px"
			 name="meterTypeId"
			 dataList="${meterTypeList}"
			 optionLabel="name"
		     optionValue="keyword" >
			</pms:unitedSelect>
            </td>
            </form>
        </tr>
        <tr>
          <td colspan="2" class="aux_intable_td1">


          <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="outtable">

  <tr>
    <td  valign="top"><div class="leftTree" >
      <table width="100%" border="0" cellspacing="0" cellpadding="0">

        <tr>
          <td height="24"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="24">&nbsp;&nbsp;已选择的列表：<span id="selectSpanMessage"></span></td>
                  </tr>
                  <tr>
                    <td><table width="100%" height="100" border="0" cellpadding="0" cellspacing="1">
                        <tr>
                          <td align="left" valign="top" nowrap class="LeftdownBlock1" style="padding:3px;"><div style="OVERFLOW: auto; WIDTH: 100%;  HEIGHT: 100%">
                              <table border="1" cellspacing="3" cellpadding="0" id="table1" class="lastselect"  style="border-collapse:collapse" bordercolor="BCBFD2" >
                                <tbody id="tableBody">

                                </tbody>
                              </table>
                          </div></td>
                        </tr>
                    </table></td>
                  </tr>
                </table>             </td>
            </tr>

          </table></td>
        </tr>
      </table>
      </div>
	  &nbsp;
	  <div class="leftTree"  >
      <table width="100%" border="0" cellspacing="0" cellpadding="0">

        <tr>
          <td height="26"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td>&nbsp;&nbsp;选择楼栋：                </td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td>
		  <div style="height:128px;overflow:auto;">
		  <table width="100%" height="100" border="0" cellpadding="0" cellspacing="1" >
                    <tr>
                      <td align="left" valign="middle" nowrap class="LeftdownBlock1" style="padding-top:3px;">
                      <table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" class="room_border">
 <tr>
 <c:forEach var="buildingSelect" items="${buildingList}" varStatus="status">
    <td width="19%" class="2td_listTable_record_off" id="${buildingSelect.keyword}" ondblclick="addNameTR('${buildingSelect.keyword}','${buildingSelect.areaName}','${buildingSelect.name}');">${buildingSelect.areaName}(${buildingSelect.name}) </td>
    <c:if test="${status.count%5==0}"></tr><tr>
     </c:if>

     <c:if test="${status.last}">


       <c:forEach var="emptyy" items="${emptyList}" varStatus="emptyStatus">
		    <td width="19%" class="2td_listTable_record_off">&nbsp;</td>
		    <c:if test="${(status.count+emptyStatus.count)%5==0}">
		    </tr>
		       <c:if test="${!emptyStatus.last}">
		        <tr>
		       </c:if>
		    </c:if>
        </c:forEach>
     </c:if>
</c:forEach>


                  </table></td>
                    </tr>
            </table>
			</div>	  </td>
        </tr>
      </table>
      </div></td>
  </tr>

</table>



          </td>
          </tr>
      </table>
	  </td>
        </tr>
      </table>
	 </td>
  </tr>
    </table></td>
	  </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2" class="window_footer"> <table border="0" cellspacing="0" cellpadding="0">
        <tr>
		  <td><table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td class="buttonOffLeft" id="btn1_21"></td>
                <td class="buttonOffMiddle" id="btn1_22" onClick="submitTable();" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onBlur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom">保存</td>
                <td class="buttonOffRight" id="btn1_23"></td>
              </tr>
          </table></td>
          <td class="btn_between_space"></td>
          <td><table border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td class="buttonOffLeft" id="btn1_31"></td>
                <td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom">关闭</td>
                <td class="buttonOffRight" id="btn1_33"></td>
              </tr>
          </table></td>
        </tr>
          </table>
      <p>&nbsp;</p></td>
  </tr>
</table>

</body>
</html>